/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.core.wicket.component.label;

import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.IFeedbackMessageFilter;

/**
 * <pre>
 * 
 * 错误级别过滤器
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public class ErrorLevelsFeedbackMessageFilter implements IFeedbackMessageFilter {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 2790998253465492707L;

	/**
	 * 过滤的级别
	 */
	private int[] filteredErrorLevels;

	public ErrorLevelsFeedbackMessageFilter(int[] filteredErrorLevels) {
		this.filteredErrorLevels = filteredErrorLevels;
	}

	public ErrorLevelsFeedbackMessageFilter(int filteredErrorLevels) {
		this.filteredErrorLevels = new int[] { filteredErrorLevels };
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.apache.wicket.feedback.IFeedbackMessageFilter#accept(org.apache.wicket
	 * .feedback.FeedbackMessage)
	 */
	@Override
	public boolean accept(FeedbackMessage message) {

		for (int errorLevel : filteredErrorLevels) {
			if (message.getLevel() == errorLevel) {
				return false;
			}
		}

		return true;
	}

}
